package com.dhcc.bpm.modules.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.system.entity.DataTable;
import com.dhcc.bpm.modules.system.entity.DataTableColumn;
import com.dhcc.bpm.modules.system.mapper.DataDictMapper;
import com.dhcc.bpm.modules.system.service.IDataDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @version V1.0
 * @ClassName IDataDictServiceImpl
 * @Author xiafayu
 * @Date 2021/3/26 16:14
 * @Copyright: 2021 东华软件.. All rights reserved.
 */
@Service("dataDict")
public class IDataDictServiceImpl implements IDataDictService {

    @Autowired
    DataDictMapper dataDictMapper;

    @Value("${spring.datasource.username}")
    private String tabUser;

    @Override
    public IPage<DataTable> selectDataTablePage(IPage<DataTable> page, DataTable dataTable) {
        dataTable.setUserName(dataDictMapper.getUserName());
        return page.setRecords(dataDictMapper.selectDataTablePage(page, dataTable));
    }

    @Override
    public IPage<DataTableColumn> selectDataTableColumnByTableName(IPage<DataTableColumn> page, String tableName) {
        return page.setRecords(dataDictMapper.selectDataTableColumnByTableName(page, tableName, tabUser.toUpperCase()));
    }
}
